import javax.swing.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Employee extends Person implements ActionListener{

	JButton okE;
	JButton closeE;
	String eID;
	String supervisor;
	String job;
	String salary;
	String fName;
	String lName;
	String mI;
	String age;
	JTextField eIDT;
	JTextField supeT;
	JTextField jobT;
	JTextField salaryT;
	public Employee()
	{	
		fName="";
		lName="";
		mI="";
		age="";
		eID="";
		supervisor="";
		job="";
		salary="";
		setLayout(new GridLayout(5, 4, 5, 5));
		JLabel eIDL= new JLabel("Employee ID: ");
		eIDT= new JTextField(16);
		JLabel supeL= new JLabel("Supervisor: ");
		supeT= new JTextField(1);
		JLabel jobL= new JLabel("Job: ");
		jobT= new JTextField(4);
		JLabel salaryL= new JLabel("Salary: ");
		salaryT= new JTextField(4);
		okE=new JButton("OK");
		closeE=new JButton("Close");
		okE.setActionCommand("OK");
		closeE.setActionCommand("CLOSE");
		okE.addActionListener(this);
		closeE.addActionListener(this);
		add(eIDL);
		add(eIDT);
		add(supeL);
		add(supeT);
		add(jobL);
		add(jobT);
		add(salaryL);
		add(salaryT);
		add(okE);
		add(closeE);
	}
	public void initialize()
	{
		this.setTitle("Employee");
		remove(ok);
		remove(close);
		this.setSize(400,300);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	public void actionPerformed(ActionEvent event)
	{
		String command=event.getActionCommand();
		if(command=="OK")
		{
			eID=eIDT.toString();
			supervisor=supeT.toString();
			job=jobT.toString();
			salary=salaryT.toString();
			fName=super.getFName();
			lName=super.getFName();
			mI=super.getMI();
			age=super.getAge();
		}
		else if(command=="CLOSE")
		{
			dispose();
		}
	}
	public String geteID()
	{
		return eID;
	}
	public String getSupervisor()
	{
		return supervisor;
	}
	public String getJob()
	{
		return job;
	}
	public String getSalary()
	{
		return salary;
	}
	public String getFNameT()
	{
		return fName;
	}
	public String getLNameT()
	{
		return lName;
	}
	public String getMIT()
	{
		return mI;
	}
	public String getAgeT()
	{
		return age;
	}
	public String toString()
	{
		return getFNameT() + " " + getLNameT() + " " + getMIT() + " " + getAgeT() +"\n"+geteID()+ " " + getSupervisor()+ " "+getJob()+ " "+ getSalary();
	}
}